package com.zhaojonhy.zhaopangwb.widget;

import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ListView;

import com.handmark.pulltorefresh.library.LoadingLayoutProxy;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.zhaojonhy.zhaopangwb.utils.DisplayUtils;

/**
 * Created by Administrator on 2016/9/21.
 */

public class Pull2RefreshListView extends PullToRefreshListView {

    public Pull2RefreshListView(Context context) {
        super(context);
    }

    public Pull2RefreshListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public Pull2RefreshListView(Context context, Mode mode) {
        super(context, mode);
    }

    public Pull2RefreshListView(Context context, Mode mode, AnimationStyle style) {
        super(context, mode, style);
    }

    @Override
    protected void onRefreshing(boolean doScroll) {
        super.onRefreshing(doScroll);
    }

    @Override
    protected void onReset() {
        super.onReset();
    }

    @Override
    protected ListView createListView(Context context, AttributeSet attrs) {
        ListView listView = super.createListView(context, attrs);

        listView.setMinimumHeight(DisplayUtils.getScreenHeightPixels( (Activity) context)) ; //设置每个Item的高度
        return listView ;
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if( onPlvScrollListener != null ){
            onPlvScrollListener.onScrollChanged(l, t, oldl, oldt);
        }
    }
    private onPlvScrollListener onPlvScrollListener ;

    public void setOnP2RefreshChangeScrollListener(onPlvScrollListener onPlvScrollListener ){
       this.onPlvScrollListener = onPlvScrollListener ;
    }

    //新建一个内部的回调接口实现下拉刷新是整体的背景图演示
    public static interface onPlvScrollListener{
        void onScrollChanged(int l, int t, int oldl, int oldt) ;
    }

}
